#include "my_gui.h"
#include "arduino.h"
#include <lvgl.h>
#include <TFT_eSPI.h>
#include "demos\lv_demos.h"

void lv_input_init(void);
void my_knob_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data) ;

void lv_menu_container_init();
void lv_stdby_contanier_init();

void lv_stdby_instrument_contanier_init();
void lv_stdby_tkr_contanier_init();

static lv_obj_t *menu_container = NULL;             // 定义容器1
static lv_obj_t *stdby_contanier = NULL;            // 定义容器
static lv_obj_t *stdby_astronaut_contanier = NULL;  // 定义容器
static lv_obj_t *stdby_instrument_contanier = NULL; // 定义容器5

int stdby_astronaut_state = 0;
int stdby_instrument_state = 0;


lv_obj_t *main_con, *main_led, *main_au, *main_scr, *main_dial;



LV_IMG_DECLARE(alpha_menu_con_pic);
LV_IMG_DECLARE(alpha_menu_led_pic);
LV_IMG_DECLARE(alpha_menu_aucfg_pic);
LV_IMG_DECLARE(alpha_menu_standby_pic);
LV_IMG_DECLARE(alpha_menu_dial_pic128);


static lv_indev_t *indev_encoder;
lv_group_t *default_g;

extern int32_t motor_gui_position;
extern int my_hx711_gui;


/*Change to your screen resolution*/
static const uint16_t screenWidth = 240;
static const uint16_t screenHeight = 240;

static lv_disp_draw_buf_t draw_buf;
static lv_color_t buf_1[screenWidth * screenHeight];
static lv_color_t buf_2[screenWidth * screenHeight];
// static lv_color_t buf_2[ screenWidth * screenHeight ];
TFT_eSPI tft = TFT_eSPI(screenWidth, screenHeight); /* TFT instance */



/* Display flushing */
void my_disp_flush(_lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
    uint32_t w = (area->x2 - area->x1 + 1);
    uint32_t h = (area->y2 - area->y1 + 1);

    tft.startWrite();
    tft.setAddrWindow(area->x1, area->y1, w, h);
    tft.pushColors((uint16_t *)&color_p->full, w * h, true);
    tft.endWrite();
    lv_disp_flush_ready(disp);
}

void my_gui_task(void *pvParameters)
{
    while (1)
    {
        lv_timer_handler(); /* let the GUI do its work */
        vTaskDelay(5);
    }
}

void my_gui_init()
{
    lv_init();
    tft.begin();        /* TFT init */
    tft.setRotation(2); /* Landscape orientation, flipped */ //原本为0
    lv_disp_draw_buf_init(&draw_buf, buf_1, buf_2, screenWidth * screenHeight);
    static lv_disp_drv_t disp_drv;
    lv_disp_drv_init(&disp_drv);
    disp_drv.hor_res = screenWidth;
    disp_drv.ver_res = screenHeight;
    disp_drv.flush_cb = my_disp_flush;
    disp_drv.draw_buf = &draw_buf;
    lv_disp_drv_register(&disp_drv);


    //lv_demo_benchmark();          // OK

    lv_input_init();
    lv_menu_container_init();

    lv_stdby_contanier_init();
    lv_stdby_instrument_contanier_init();
    lv_stdby_tkr_contanier_init();


    lv_obj_clear_flag(menu_container, LV_OBJ_FLAG_HIDDEN);//主菜单

    lv_obj_add_flag(stdby_contanier, LV_OBJ_FLAG_HIDDEN);//2个logo 太空人 系统状态图标
    lv_obj_add_flag(stdby_instrument_contanier, LV_OBJ_FLAG_HIDDEN);//系统状态 CPU RAM
    lv_obj_add_flag(stdby_astronaut_contanier, LV_OBJ_FLAG_HIDDEN);//太空人转圈



    /*
    xTaskCreatePinnedToCore() 函数有 7 个参数：
    1.实现任务的函数名（task1）
    2.任务的任何名称（“task1”等）
    3.以字为单位分配给任务的堆栈大小（1 个字=2 字节）
    4.任务输入参数（可以为NULL）
    5.任务的优先级（0为最低优先级）
    6.任务句柄（可以为 NULL）
    7.任务将运行的核心 ID（0 或 1）
    */
    xTaskCreatePinnedToCore(my_gui_task, "my_gui_task", 20480, NULL, 2, NULL, 1);
}


void lv_input_init(void)
{
    static lv_indev_drv_t indev_drv;
    lv_indev_drv_init(&indev_drv);
    indev_drv.type = LV_INDEV_TYPE_KEYPAD; // LV_INDEV_TYPE_ENCODER
    indev_drv.read_cb = my_knob_read;
    indev_encoder = lv_indev_drv_register(&indev_drv);

    //   menu_g = lv_group_create();                   // 创建组
    default_g = lv_group_create();                // 创建组
    lv_group_set_default(default_g);              // 设置组(group)为默认模式,后面的部件创建时会自动加入组(group)
                                                  //  lv_indev_set_group(indev_encoder, menu_g);    // 将输入设备(indev)和组(group)关联起来
    lv_indev_set_group(indev_encoder, default_g); // 将输入设备(indev)和组(group)关联起来
                                                  //   lv_group_set_wrap(menu_g,1);
}


void my_knob_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data) // 传递键值给LVGL
{
    static int32_t last_motor_gui_position = 0;
    static u_int8_t hsv_flag = 0, last_hsv_flag = 0;
    byte rec[5] = {0};
       
    if (stdby_instrument_state == 1) //按下电机，返回主页 显示CPU GPU RAM占用率(串口发过来数据)
    {
        if (my_hx711_gui == 1)
        {
            my_hx711_gui = 0;
            stdby_instrument_state = 0;
   
            lv_obj_clear_flag(menu_container, LV_OBJ_FLAG_HIDDEN);

         
            lv_obj_add_flag(stdby_contanier, LV_OBJ_FLAG_HIDDEN);
            lv_obj_add_flag(stdby_instrument_contanier, LV_OBJ_FLAG_HIDDEN);
            lv_obj_add_flag(stdby_astronaut_contanier, LV_OBJ_FLAG_HIDDEN);
        }
    }
    else if (stdby_astronaut_state == 1)//按下电机，返回主页
    {
        if (my_hx711_gui == 1)
        {
            my_hx711_gui = 0;
            stdby_astronaut_state = 0;
       
            lv_obj_clear_flag(menu_container, LV_OBJ_FLAG_HIDDEN);
           
       
            lv_obj_add_flag(stdby_contanier, LV_OBJ_FLAG_HIDDEN);
            lv_obj_add_flag(stdby_instrument_contanier, LV_OBJ_FLAG_HIDDEN);
            lv_obj_add_flag(stdby_astronaut_contanier, LV_OBJ_FLAG_HIDDEN);
        }
    }
    else // 普通模式     //按下电机确认， 旋转电机，前后切换
    {
        if (last_motor_gui_position != motor_gui_position)
        {
            if (last_motor_gui_position < motor_gui_position)
            {
                data->state = LV_INDEV_STATE_PR;
                data->key = LV_KEY_NEXT;
                //   Serial.print("LV_KEY_NEXT");
            }
            else
            {
                data->state = LV_INDEV_STATE_PR;
                data->key = LV_KEY_PREV;
                //   Serial.print("LV_KEY_PREV");
            }
        }
        else
        {
            data->state = LV_INDEV_STATE_REL;
        }
        last_motor_gui_position = motor_gui_position;
        // Serial.print("config.position = ");
        // Serial.println(motor_gui_position);
        if (my_hx711_gui == 1)
        {
            my_hx711_gui = 0;
            data->key = LV_KEY_ENTER;
            data->state = LV_INDEV_STATE_PRESSED;
            // Serial.println("LV_KEY_ENTER");
        }
        else if (my_hx711_gui == 2)
        {
            my_hx711_gui = 0;
            data->key = LV_KEY_ENTER;
            data->state = LV_INDEV_STATE_RELEASED;
        }
    }
}
/**
 * @brief 处理按钮事件的回调函数
 * @param event
 */
static void application_button_event_cb(lv_event_t *event)
{

    lv_obj_t *current_btn = lv_event_get_current_target(event);
    // Serial.println("LV_EVENT_FOCUSED");
    if (event->code == LV_EVENT_FOCUSED)//对象被聚焦
    {
        //  printf("LV_EVENT_FOCUSED");
        uint32_t current_btn_index = lv_obj_get_index(current_btn);
        uint32_t mid_btn_index = (lv_obj_get_child_cnt(menu_container) - 1) / 2;
        //uint32_t mid_btn_index = 2;
        if (current_btn_index > mid_btn_index)
        {
            lv_obj_scroll_to_view(lv_obj_get_child(menu_container, mid_btn_index - 1), LV_ANIM_OFF);
            lv_obj_scroll_to_view(lv_obj_get_child(menu_container, mid_btn_index), LV_ANIM_ON);
            lv_obj_move_to_index(lv_obj_get_child(menu_container, 0), -1);
        }
        else if (current_btn_index < mid_btn_index)
        {
            lv_obj_scroll_to_view(lv_obj_get_child(menu_container, mid_btn_index + 1), LV_ANIM_OFF);
            lv_obj_scroll_to_view(lv_obj_get_child(menu_container, mid_btn_index), LV_ANIM_ON);
            lv_obj_move_to_index(lv_obj_get_child(menu_container, -1), 0);
        }

        for (uint8_t i = 0; i < 3; i++)
        {
            lv_obj_set_size(lv_obj_get_child(menu_container, mid_btn_index - i), 100 - i * 50, 100 - i * 50);
            lv_obj_set_size(lv_obj_get_child(menu_container, mid_btn_index + i), 100 - i * 50, 100 - i * 50);
      
        }
    }
    else if (event->code == LV_EVENT_SIZE_CHANGED)//  对象坐标/大小改变
    {
        //   Serial.println("LV_EVENT_SIZE_CHANGED");

        /*缩放图标*/
        lv_obj_t *img = lv_obj_get_child(current_btn, 0);

        if (lv_obj_is_valid(img))
        {
            lv_img_set_zoom(img, (uint16_t)(lv_obj_get_width(current_btn) * 0.9 / 128 * LV_IMG_ZOOM_NONE));
        }
    }
    else if (event->code == LV_EVENT_SCROLL)
    {
        LV_LOG_ERROR("H");
    }
    else if (event->code == LV_EVENT_PRESSED)
    {
        lv_obj_t *obj = lv_event_get_target(event);
        void *user_data = lv_event_get_user_data(event);
    
    
        if (user_data == (void *)5)
        {
            lv_obj_add_flag(menu_container, LV_OBJ_FLAG_HIDDEN);
         
            lv_obj_add_flag(stdby_instrument_contanier, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(stdby_contanier, LV_OBJ_FLAG_HIDDEN);
            lv_obj_add_flag(stdby_astronaut_contanier, LV_OBJ_FLAG_HIDDEN);
        
        }

       else if (user_data == (void *)31)
        {
            lv_obj_add_flag(menu_container, LV_OBJ_FLAG_HIDDEN);

            lv_obj_add_flag(stdby_contanier, LV_OBJ_FLAG_HIDDEN);
            lv_obj_add_flag(stdby_instrument_contanier, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(stdby_astronaut_contanier, LV_OBJ_FLAG_HIDDEN);

            stdby_astronaut_state = 1;
        }
       else if (user_data == (void *)32)
        {
            // 这是控件2的操作
            lv_obj_add_flag(menu_container, LV_OBJ_FLAG_HIDDEN);

            lv_obj_add_flag(stdby_contanier, LV_OBJ_FLAG_HIDDEN);
            lv_obj_clear_flag(stdby_instrument_contanier, LV_OBJ_FLAG_HIDDEN);
            lv_obj_add_flag(stdby_astronaut_contanier, LV_OBJ_FLAG_HIDDEN);
            stdby_instrument_state = 1;
        }
 
    }
}

void lv_menu_container_init()
{
    // contanier1容器里装载滚动图标
    menu_container = lv_obj_create(lv_scr_act());
    // lv_obj_set_size(container, LV_PCT(240), LV_PCT(240));
    lv_obj_set_size(menu_container, 240, 240);
    lv_obj_set_scrollbar_mode(menu_container, LV_SCROLLBAR_MODE_OFF);
    lv_obj_set_flex_flow(menu_container, LV_FLEX_FLOW_ROW);
    lv_obj_set_flex_align(menu_container, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
    lv_obj_set_scroll_snap_x(menu_container, LV_SCROLL_SNAP_CENTER);//捕捉
    lv_obj_set_style_bg_opa(menu_container, LV_OPA_100, LV_PART_MAIN); // LV_OPA_100
    lv_obj_set_style_bg_color(menu_container, lv_color_black(), LV_PART_MAIN);
    lv_obj_set_style_border_width(menu_container, 0, LV_PART_MAIN);
    lv_obj_set_style_pad_column(menu_container, 10, LV_PART_MAIN); // 图标之间的间隙
    lv_obj_center(menu_container);

    // 创建主菜单中的con图片按钮
    main_con = lv_btn_create(menu_container); // 在con_contanier画布上创建一个按钮
    lv_obj_set_size(main_con, 128, 128);
    lv_obj_add_event_cb(main_con, application_button_event_cb, LV_EVENT_FOCUSED, (void *)1);      // 添加事件回调函数
    lv_obj_add_event_cb(main_con, application_button_event_cb, LV_EVENT_PRESSED, (void *)1);      // 添加事件回调函数
    lv_obj_add_event_cb(main_con, application_button_event_cb, LV_EVENT_SIZE_CHANGED, (void *)1); // 添加事件回调函数
    lv_obj_remove_style_all(main_con);
    lv_obj_set_style_bg_opa(main_con, LV_OPA_0, LV_PART_MAIN); // 设置背景色透明
    lv_obj_t *main_con_btn_img = lv_img_create(main_con);      // 在按钮上创建一个图片
    lv_img_set_src(main_con_btn_img, &alpha_menu_con_pic);     // 设置图片源
    lv_obj_center(main_con_btn_img);                           // 图片居中

    // 创建主菜单中的led图片按钮
    main_led = lv_btn_create(menu_container); // 在con_contanier画布上创建一个按钮
    lv_obj_set_size(main_led, 128, 128);
    lv_obj_add_event_cb(main_led, application_button_event_cb, LV_EVENT_FOCUSED, (void *)2);      // 添加事件回调函数
    lv_obj_add_event_cb(main_led, application_button_event_cb, LV_EVENT_PRESSED, (void *)2);      // 添加事件回调函数
    lv_obj_add_event_cb(main_led, application_button_event_cb, LV_EVENT_SIZE_CHANGED, (void *)2); // 添加事件回调函数
    lv_obj_remove_style_all(main_led);
    lv_obj_set_style_bg_opa(main_led, LV_OPA_0, LV_PART_MAIN); // 设置背景色透明
    lv_obj_t *main_led_btn_img = lv_img_create(main_led);      // 在按钮上创建一个图片
    lv_img_set_src(main_led_btn_img, &alpha_menu_led_pic);     // 设置图片源
    lv_obj_center(main_led_btn_img);                           // 图片居中


    // 创建主菜单中的au图片按钮
    main_au = lv_btn_create(menu_container); // 在con_contanier画布上创建一个按钮
    lv_obj_set_size(main_au, 128, 128);
    lv_obj_add_event_cb(main_au, application_button_event_cb, LV_EVENT_FOCUSED, (void *)4);      // 添加事件回调函数
    lv_obj_add_event_cb(main_au, application_button_event_cb, LV_EVENT_PRESSED, (void *)4);      // 添加事件回调函数
    lv_obj_add_event_cb(main_au, application_button_event_cb, LV_EVENT_SIZE_CHANGED, (void *)4); // 添加事件回调函数
    lv_obj_remove_style_all(main_au);
    lv_obj_set_style_bg_opa(main_au, LV_OPA_0, LV_PART_MAIN); // 设置背景色透明
    lv_obj_t *main_au_btn_img = lv_img_create(main_au);       // 在按钮上创建一个图片
    lv_img_set_src(main_au_btn_img, &alpha_menu_aucfg_pic);   // 设置图片源
    lv_obj_center(main_au_btn_img);                           // 图片居中

    // 创建主菜单中的scr图片按钮
    main_scr = lv_btn_create(menu_container); // 在con_contanier画布上创建一个按钮
    lv_obj_set_size(main_scr, 128, 128);
    lv_obj_add_event_cb(main_scr, application_button_event_cb, LV_EVENT_FOCUSED, (void *)5);      // 添加事件回调函数
    lv_obj_add_event_cb(main_scr, application_button_event_cb, LV_EVENT_PRESSED, (void *)5);      // 添加事件回调函数
    lv_obj_add_event_cb(main_scr, application_button_event_cb, LV_EVENT_SIZE_CHANGED, (void *)5); // 添加事件回调函数
    lv_obj_remove_style_all(main_scr);
    lv_obj_set_style_bg_opa(main_scr, LV_OPA_0, LV_PART_MAIN); // 设置背景色透明
    lv_obj_t *main_scr_btn_img = lv_img_create(main_scr);      // 在按钮上创建一个图片
    lv_img_set_src(main_scr_btn_img, &alpha_menu_standby_pic); // 设置图片源
    lv_obj_center(main_scr_btn_img);                           // 图片居中

    // 创建主菜单中的surface dial图片按钮
    main_dial = lv_btn_create(menu_container); // 在con_contanier画布上创建一个按钮
    lv_obj_set_size(main_dial, 128, 128);
    lv_obj_add_event_cb(main_dial, application_button_event_cb, LV_EVENT_FOCUSED, (void *)6);      // 添加事件回调函数
    lv_obj_add_event_cb(main_dial, application_button_event_cb, LV_EVENT_PRESSED, (void *)6);      // 添加事件回调函数
    lv_obj_add_event_cb(main_dial, application_button_event_cb, LV_EVENT_SIZE_CHANGED, (void *)6); // 添加事件回调函数
    lv_obj_remove_style_all(main_dial);
    lv_obj_set_style_bg_opa(main_dial, LV_OPA_0, LV_PART_MAIN); // 设置背景色透明
    lv_obj_t *main_dial_btn_img = lv_img_create(main_dial);     // 在按钮上创建一个图片
    lv_img_set_src(main_dial_btn_img, &alpha_menu_dial_pic128); // 设置图片源
    lv_obj_center(main_dial_btn_img);                           // 图片居中
 
}

void lv_stdby_contanier_init(void)
{
    lv_obj_t *obj;
    stdby_contanier = lv_obj_create(lv_scr_act());
    lv_obj_set_size(stdby_contanier, 240, 240);
    //lv_obj_set_style_radius(stdby_contanier, 0, 100);
    //lv_obj_set_style_bg_opa(stdby_contanier, LV_OPA_100, LV_PART_MAIN); // LV_OPA_100
    //lv_obj_set_style_bg_color(stdby_contanier, lv_color_black(), LV_PART_MAIN);

    //lv_obj_set_size(stdby_contanier, LV_PCT(240), LV_PCT(240));
    lv_obj_set_scrollbar_mode(stdby_contanier, LV_SCROLLBAR_MODE_OFF);
    lv_obj_set_flex_flow(stdby_contanier, LV_FLEX_FLOW_ROW);
    lv_obj_set_flex_align(stdby_contanier, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
    lv_obj_set_scroll_snap_x(stdby_contanier, LV_SCROLL_SNAP_CENTER);
    lv_obj_set_style_bg_opa(stdby_contanier, LV_OPA_100, LV_PART_MAIN);
    lv_obj_set_style_bg_color(stdby_contanier, lv_color_black(), LV_PART_MAIN);
    lv_obj_set_style_border_width(stdby_contanier, 0, LV_PART_MAIN);
    lv_obj_set_style_pad_column(stdby_contanier, 20, LV_PART_MAIN); // 图标之间的间隙
    lv_obj_center(stdby_contanier);

    // 生成演示按钮 
    lv_obj_t *stdby_astronaut_btn = lv_btn_create(stdby_contanier);                                           // 在con_contanier画布上创建一个按钮
    lv_obj_set_size(stdby_astronaut_btn, 128, 128);                                                             // 设置按钮尺寸
    lv_obj_align(stdby_astronaut_btn, LV_ALIGN_LEFT_MID, 0, 0);                                               // 设置按钮顶部居中对齐
    lv_obj_add_event_cb(stdby_astronaut_btn, application_button_event_cb, LV_EVENT_FOCUSED, (void *)31);      // 对象被聚焦
    lv_obj_add_event_cb(stdby_astronaut_btn, application_button_event_cb, LV_EVENT_PRESSED, (void *)31);      // 对象被按下
    lv_obj_add_event_cb(stdby_astronaut_btn, application_button_event_cb, LV_EVENT_SIZE_CHANGED, (void *)31); // 对象坐标/大小已更改 
    lv_obj_remove_style_all(stdby_astronaut_btn);
    lv_obj_set_style_bg_opa(stdby_astronaut_btn, LV_OPA_0, LV_PART_MAIN);                                     // 设置背景色透明
    lv_obj_t *stdby_astronaut_img = lv_img_create(stdby_astronaut_btn);                                       // 在按钮上创建一个图片
    lv_img_set_src(stdby_astronaut_img, &alpha_stdby_astronaut_pic);                                          // 设置图片源
    lv_obj_center(stdby_astronaut_img);                                                                       // 图片居中

    lv_obj_t *stdby_instrument_btn = lv_btn_create(stdby_contanier);                                           // 在con_contanier画布上创建一个按钮
    lv_obj_set_size(stdby_instrument_btn, 128, 128);                                                             // 设置按钮尺寸
    lv_obj_align(stdby_instrument_btn, LV_ALIGN_LEFT_MID, 0, 0);                                               // 设置按钮顶部居中对齐
    lv_obj_add_event_cb(stdby_instrument_btn, application_button_event_cb, LV_EVENT_FOCUSED, (void *)32);      // 添加事件回调函数
    lv_obj_add_event_cb(stdby_instrument_btn, application_button_event_cb, LV_EVENT_PRESSED, (void *)32);      // 添加事件回调函数
    lv_obj_add_event_cb(stdby_instrument_btn, application_button_event_cb, LV_EVENT_SIZE_CHANGED, (void *)32); // 添加事件回调函数
    lv_obj_remove_style_all(stdby_instrument_btn);
    lv_obj_set_style_bg_opa(stdby_instrument_btn, LV_OPA_0, LV_PART_MAIN);                                     // 设置背景色透明
    lv_obj_t *stdby_instrument_img = lv_img_create(stdby_instrument_btn);                                      // 在按钮上创建一个图片
    lv_img_set_src(stdby_instrument_img, &alpha_stdby_instrument_pic);                                         // 设置图片源
    lv_obj_center(stdby_instrument_img);                                                                       // 图片居中
}
void lv_stdby_instrument_contanier_init(void)
{
    // stdby_instrument_contanier = lv_obj_create(lv_scr_act());
    // lv_obj_set_size(stdby_instrument_contanier, 240, 240);
    // lv_obj_set_style_radius(stdby_instrument_contanier, 0, 100);

    static lv_style_t style;        // 创建样式
    lv_style_init(&style);          // 初始化样式
    lv_style_set_radius(&style, 5); // 设置圆角半径

    //  LV_IMG_DECLARE(animimg001);                                           // 加载图片声明 .c文件的图片
    lv_style_set_bg_img_src(&style, &alpha_instrument_pic); // 设置背景图片
    lv_style_set_bg_img_opa(&style, LV_OPA_100);            // 设置背景图片透明度
    // lv_style_set_bg_img_recolor(&style, lv_palette_main(LV_PALETTE_RED)); // 设置背景图片重着色
    // lv_style_set_bg_img_recolor_opa(&style, LV_OPA_80);                   // 设置背景图片重着色透明度
    // lv_style_set_bg_img_tiled(&style, false);                             // 设置背景图片平铺

    /*Create an object with the new style*/
    stdby_instrument_contanier = lv_obj_create(lv_scr_act()); // 创建对象
    lv_obj_add_style(stdby_instrument_contanier, &style, 0);  // 设置对象的样式
    lv_obj_set_size(stdby_instrument_contanier, 240, 240);    // 设置对象的尺寸
    lv_obj_center(stdby_instrument_contanier);                // 居中对象
    lv_obj_set_style_bg_opa(stdby_instrument_contanier, LV_OPA_0, LV_PART_MAIN);

}
void lv_stdby_tkr_contanier_init(void)
{
    static const void *astronauts_anim_imgs[13] = {
        &tkr01,
        &tkr02,
        &tkr03,
        &tkr04,
        &tkr05,
        &tkr06,
        &tkr07,
        &tkr08,
        &tkr09,
        &tkr10,
        &tkr11,
        &tkr12,
        &tkr13,
    };
    stdby_astronaut_contanier = lv_animimg_create(lv_scr_act());                     // 创建动画对象
    lv_obj_center(stdby_astronaut_contanier);                                        // 将对象置于屏幕中央
    lv_animimg_set_src(stdby_astronaut_contanier, astronauts_anim_imgs, 13);         // lv_animimg_set_src(animimg1, (lv_img_dsc_t **)astronauts_anim_imgs, 3); // 加载动画资源
    lv_animimg_set_duration(stdby_astronaut_contanier, 1000);                        // 创建动画时间
    lv_animimg_set_repeat_count(stdby_astronaut_contanier, LV_ANIM_REPEAT_INFINITE); // 设置一直重复时间
    lv_animimg_start(stdby_astronaut_contanier);
}
